package com.ungs.bo.impl;

import java.util.ArrayList;
import java.util.List;

import com.ungs.bo.DetalleStockBO;
import com.ungs.dao.DetalleStockDAO;
import com.ungs.dao.impl.DetalleStockDAOImpl;
import com.ungs.entities.DetalleStock;
import com.ungs.entities.StockMaterial;
import com.ungs.utils.Constantes;

public class DetalleStockBOImpl extends EntidadBOImpl<DetalleStock> implements
		DetalleStockBO {	
	private DetalleStockDAO detalleStockDAO = new DetalleStockDAOImpl();

	@Override
	public List<DetalleStock> getDetalleByStockMaterial(
			StockMaterial stockMaterial) {
		return detalleStockDAO.getDetalleByStockMaterial(stockMaterial);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<DetalleStock> getAllDetalleStock() {
		List<DetalleStock> detalleStockList = (List<DetalleStock>) getAll(DetalleStock.class);
		List<DetalleStock> detalleStocklReturn = new ArrayList<DetalleStock>();

		logger.info("Obteniendo lista de detalle stock con alta logica");
		for (DetalleStock detalleStock : detalleStockList) {
			if (detalleStock.getEstadoLogico().equals(Constantes.ALTA)) {
				detalleStocklReturn.add(detalleStock);
			}
		}

		return detalleStocklReturn;
	}

	@Override
	public void eliminarDetalleStock(DetalleStock detalleStock) {
		logger.info("Baja logica detalleStock: " + detalleStock.getId());
		detalleStock.setEstadoLogico(Constantes.BAJA);
		actualizar(detalleStock);

	}

}
